home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Software Contest 3 / FM Towns Software Contest 3.iso / exp / astral / a1 / game / source / star.c < prev    next >
C/C++ Source or Header  |  1994-01-07  |  4KB  |  120 lines

  1. // "star.c"
  2. // 背景(宇宙空間)を表示
  3.  
  4. #include "wire3d.h"
  5. #include "sin8.c"
  6.  
  7. void star(ANGLE *angle,int page)
  8. {
  9.     int i,x,y,z_w;
  10.     int point_w[4][3];
  11.     
  12.     #define STAR_NUM 38
  13.     
  14.     int star_data[STAR_NUM][3]={{ 100000, 100000, 100000},
  15.                                 {-100000, 100000, 100000},
  16.                                 { 100000,-100000, 100000},
  17.                                 {-100000,-100000, 100000},
  18.                                 { 100000, 100000,-100000},
  19.                                 {-100000, 100000,-100000},
  20.                                 { 100000,-100000,-100000},
  21.                                 {-100000,-100000,-100000},
  22.                                 {- 60000,  30000, 100000},
  23.                                 {- 20000,- 40000, 100000},
  24.                                 {  10000,  50000, 100000},
  25.                                 {  15000,- 80000, 100000},
  26.                                 {  70000,- 10000, 100000},
  27.                                 {  60000,- 30000,-100000},
  28.                                 {  20000,  40000,-100000},
  29.                                 {- 10000,- 50000,-100000},
  30.                                 {- 15000,  80000,-100000},
  31.                                 {- 70000,  10000,-100000},
  32.                                 {  60000, 100000,- 30000},
  33.                                 {  20000, 100000,  40000},
  34.                                 {- 10000, 100000,- 50000},
  35.                                 {- 15000, 100000,  80000},
  36.                                 {- 70000, 100000,  10000},
  37.                                 {  60000,-100000,- 30000},
  38.                                 {  20000,-100000,  40000},
  39.                                 {- 10000,-100000,- 50000},
  40.                                 {- 15000,-100000,  80000},
  41.                                 {- 70000,-100000,  10000},
  42.                                 { 100000,  60000,- 30000},
  43.                                 { 100000,  20000,  40000},
  44.                                 { 100000, -10000,- 50000},
  45.                                 { 100000, -15000,  80000},
  46.                                 { 100000, -70000,  10000},
  47.                                 {-100000,- 30000,  60000},
  48.                                 {-100000,  40000,  20000},
  49.                                 {-100000,- 50000,- 10000},
  50.                                 {-100000,  80000,- 15000},
  51.                                 {-100000,  10000,- 70000}};
  52.     
  53.     int color[STAR_NUM]={ COLOR(31,31,31),
  54.                           COLOR(28,22,31),
  55.                           COLOR(20,20,24),
  56.                           COLOR(28,24,29),
  57.                           COLOR(31,31,31),
  58.                           COLOR(31,31,31),
  59.                           COLOR(31,31,31),
  60.                           COLOR(31,31,31),
  61.                           COLOR(24,31,20),
  62.                           COLOR(24,18,31),
  63.                           COLOR(31,31,31),
  64.                           COLOR(20,20,28),
  65.                           COLOR(31,20,28),
  66.                           COLOR(24,31,20),
  67.                           COLOR(24,18,31),
  68.                           COLOR(31,31,31),
  69.                           COLOR(20,20,28),
  70.                           COLOR(31,20,28),
  71.                           COLOR(24,31,20),
  72.                           COLOR(24,18,31),
  73.                           COLOR(31,31,31),
  74.                           COLOR(20,20,28),
  75.                           COLOR(31,20,28),
  76.                           COLOR(31,31,31),
  77.                           COLOR(31,20,28),
  78.                           COLOR(24,31,20),
  79.                           COLOR(24,18,31),
  80.                           COLOR(31,31,31),
  81.                           COLOR(20,20,28),
  82.                           COLOR(31,20,28),
  83.                           COLOR(24,31,20),
  84.                           COLOR(24,18,31),
  85.                           COLOR(31,31,31),
  86.                           COLOR(20,20,28),
  87.                           COLOR(24,31,20),
  88.                           COLOR(24,18,31),
  89.                           COLOR(31,31,31),
  90.                           COLOR(20,20,28)};
  91.     
  92.     for(i=0;i<STAR_NUM;i++){
  93.         // Y軸の回転
  94.         point_w[1][0]=( star_data[i][0] * cos_data[angle[1]] +
  95.          star_data[i][2] * sin_data[angle[1]] )>>7;
  96.         point_w[1][2]=(-star_data[i][0] * sin_data[angle[1]] +
  97.          star_data[i][2] * cos_data[angle[1]] )>>7;
  98.         
  99.         // X軸の回転
  100.         point_w[2][1]=( star_data[i][1] * cos_data[angle[0]] -
  101.          point_w[1][2] * sin_data[angle[0]])>>7;
  102.         point_w[3][2]=((star_data[i][1] * sin_data[angle[0]] +
  103.          point_w[1][2] * cos_data[angle[0]])>>7);
  104.         
  105.         // Z軸の回転
  106.         point_w[3][0]=((point_w[1][0] * cos_data[angle[2]] -
  107.          point_w[2][1] * sin_data[angle[2]])>>7);
  108.         point_w[3][1]=((point_w[1][0] * sin_data[angle[2]] +
  109.          point_w[2][1] * cos_data[angle[2]])>>7);
  110.         
  111.         // 透視変換&描画
  112.         if(point_w[3][2]<=0)continue;
  113.         z_w=100000+0x100;
  114.         x=(( point_w[3][0]<<8)/z_w)+128;
  115.         y=((-point_w[3][1]<<8)/z_w)+120;
  116.         if(x>=0 && x<=255 && y>=0 && y<=255)
  117.             pset(x,y,color[i],page);
  118.     }
  119. }
  120.